/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.giant.entities.pos;

import com.giant.entities.InInventory;
import com.giant.entities.TypeTax;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Harold
 */
@Entity
@Table(name = "p_invoice_prod")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PInvoiceProd.findAll", query = "SELECT p FROM PInvoiceProd p"),
    @NamedQuery(name = "PInvoiceProd.findByIdInvoiceProd", query = "SELECT p FROM PInvoiceProd p WHERE p.idInvoiceProd = :idInvoiceProd"),
    @NamedQuery(name = "PInvoiceProd.findByGrossValue", query = "SELECT p FROM PInvoiceProd p WHERE p.grossValue = :grossValue"),
    @NamedQuery(name = "PInvoiceProd.findByTaxValue", query = "SELECT p FROM PInvoiceProd p WHERE p.taxValue = :taxValue"),
    @NamedQuery(name = "PInvoiceProd.findByTotalValue", query = "SELECT p FROM PInvoiceProd p WHERE p.totalValue = :totalValue")})
public class PInvoiceProd implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_invoice_prod")
    private Integer idInvoiceProd;
    @OneToOne
    @JoinColumn(name = "id_inventory")
    private InInventory idInventory;
    @Basic(optional = false)
    @NotNull
    @Column(name = "unit_value")
    private float unitValue;
    @Basic(optional = false)
    @NotNull
    @Column(name = "gross_value")
    private float grossValue;
    @Basic(optional = false)
    @NotNull
    @Column(name = "tax_value")
    private float taxValue;
    @OneToOne
    @JoinColumn(name = "id_type_tax")
    private TypeTax idTypeTax;
    @Basic(optional = false)
    @NotNull
    @Column(name = "discount_percentage")
    private float discountPercentage;
    @Basic(optional = false)
    @NotNull
    @Column(name = "total_value")
    private float totalValue;
    @JoinColumn(name = "id_invoice", referencedColumnName = "id_invoice")
    @ManyToOne(optional = false)
    private PInvoice idInvoice;
    
    public PInvoiceProd() {
    }

    public PInvoiceProd(Integer idInvoiceProd) {
        this.idInvoiceProd = idInvoiceProd;
    }

    public PInvoiceProd(Integer idInvoiceProd, float grossValue, float taxValue, float totalValue) {
        this.idInvoiceProd = idInvoiceProd;
        this.grossValue = grossValue;
        this.taxValue = taxValue;
        this.totalValue = totalValue;
    }

    public Integer getIdInvoiceProd() {
        return idInvoiceProd;
    }

    public void setIdInvoiceProd(Integer idInvoiceProd) {
        this.idInvoiceProd = idInvoiceProd;
    }

    public float getGrossValue() {
        return grossValue;
    }

    public void setGrossValue(float grossValue) {
        this.grossValue = grossValue;
    }

    public float getTaxValue() {
        return taxValue;
    }

    public void setTaxValue(float taxValue) {
        this.taxValue = taxValue;
    }

    public float getUnitValue() {
        return unitValue;
    }

    public void setUnitValue(float unitValue) {
        this.unitValue = unitValue;
    }  

    public float getTotalValue() {
        return totalValue;
    }

    public void setTotalValue(float totalValue) {
        this.totalValue = totalValue;
    }

    public float getDiscountPercentage() {
        return discountPercentage;
    }

    public void setDiscountPercentage(float discountPercentage) {
        this.discountPercentage = discountPercentage;
    }

    public PInvoice getIdInvoice() {
        return idInvoice;
    }

    public void setIdInvoice(PInvoice idInvoice) {
        this.idInvoice = idInvoice;
    }

    public InInventory getIdInventory() {
        return idInventory;
    }

    public void setIdInventory(InInventory idInventory) {
        this.idInventory = idInventory;
    }

    public TypeTax getIdTypeTax() {
        return idTypeTax;
    }

    public void setIdTypeTax(TypeTax idTypeTax) {
        this.idTypeTax = idTypeTax;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idInvoiceProd != null ? idInvoiceProd.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PInvoiceProd)) {
            return false;
        }
        PInvoiceProd other = (PInvoiceProd) object;
        if ((this.idInvoiceProd == null && other.idInvoiceProd != null) || (this.idInvoiceProd != null && !this.idInvoiceProd.equals(other.idInvoiceProd))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.giant.entities.PInvoiceProd[ idInvoiceProd=" + idInvoiceProd + " ]";
    }
}
